<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:mo="https://gitee.com/aun/Timo">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
</head>
<body class="timo-layout-page">
    <div class="layui-card">
        <div class="layui-card-header timo-card-header">
            <span><i class="fa fa-bars"></i> 商家管理</span>
            <i class="layui-icon layui-icon-refresh refresh-btn"></i>
        </div>
        <div class="layui-card-body">
            <div class="layui-row timo-card-screen">
                <div class="pull-left layui-form-pane timo-search-box">
                    <div class="layui-inline">
                        <label class="layui-form-label">状态</label>
                        <div class="layui-input-block timo-search-status">
                            <select class="timo-search-select" name="status" mo:dict="SEARCH_STATUS" mo-selected="${param.status}"></select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">分类</label>
                        <div class="layui-input-block timo-search-status" style="width: 120px;">
                            <select class="timo-search-select" name="typeId" style="width: 120px;">
                                <option value="">分类</option>
                                <option th:each="category: ${typelist}"
                                        th:text="${category.title}"
                                        th:value="${category.id}"
                                        th:selected="${category.id == typeId}"
                                        th:name="${category.title}">
                                </option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">商家名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="store_name" th:value="${param.store_name}" placeholder="请输入商家名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn timo-search-btn">
                            <i class="fa fa-search"></i>
                        </button>
                    </div>
                </div>
                <div class="pull-right screen-btn-group">
                  
                </div>
            </div>
            <div class="timo-table-wrap">
                <table class="layui-table timo-table">
                    <thead>
                    <tr>
                       <!--  <th class="timo-table-checkbox">
                            <label class="timo-checkbox"><input type="checkbox">
                                <i class="layui-icon layui-icon-ok"></i></label>
                        </th> -->
                        <th>主键ID</th>
                        <th>用户</th>
                        <th>商家名称</th>
                        <th>商家电话</th>
                        <th>星级</th>
                        <th>一级分类</th>
                        
                        <th>创建时间</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="item:${list}">
                    <!--     <td><label class="timo-checkbox"><input type="checkbox" th:value="${item.id}">
                            <i class="layui-icon layui-icon-ok"></i></label></td>
                     -->    <td th:text="${item.id}">主键ID</td>
                        <td th:text="${item?.member?.nickname}">用户</td>
                        <td th:text="${item.store_name}">商家名称</td>
                        <td th:text="${item.store_tel}">商家电话</td>
                        <td th:text="${item.store_star+'星'}">星级</td>
                        <td th:text="${item?.storetype?.title}">一级分类</td>
                        <td th:text="${#dates.format(item.createDate, 'yyyy-MM-dd HH:mm:ss')}">创建时间</td>
                        <td th:switch="${item.istop}">
                           <span th:case="0">普通</span>
                           <span th:case="1">置顶</span>
                        </td>
                        <td>
                            <a class="open-popup" data-title="详细信息" th:attr="data-url=@{'/agent/store/detail/'+${item.id}}" data-size="max" href="#">详细</a>
                            <a class="open-popup" data-title="编辑商家管理" th:attr="data-url=@{'/agent/store/edit/'+${item.id}}" data-size="max" href="#">编辑</a>
                            <a class="ajax-get" th:attr="data-msg='您是否下架'+${item.store_name}" th:href="@{/agent/store/refundStore(id=${item.id})}">下架</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <div th:replace="/common/fragment :: page"></div>
        </div>
    </div>
<script th:replace="/common/agenttemplate :: agentscript"></script>
<script>
    layui.use(['upload','laydate'], function(){
        var $=layui.jquery;
        storeType();
        //获取所有门店类型
        function storeType(){
            if($("#storeTypeAll").children('option').length > 2){
                return false;
            }
            $.ajax({
                type:'POST',
                url:'/store/type/makeStoreTypeSelect',
                async : false,
                success : function(result){
                    console.log("makeStoreTypeSelect : ------>"+result)
                    $('#storeTypeAll').empty();
                    var array=new Array;
                    array= JSON.parse(result);
                    var select="<option name='en' value=''>全部</option>";
                    for (var i=0;i<array.length;i++)
                    {
                        select=select+"<option name='en' value="+array[i].id+">"+array[i].title+"</option>";
                    }
                    $('#storeTypeAll').append(select);
                    form.render('select');
                }
            })
        }
    });
</script>
</body>
</html>